From 33548d1102318e40e4d7b9d234b513f309bde741 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 17 Mar 2009 10:42:32 +0000 Subject: [PATCH] xend: Use AUTO_PHP_SLOT_STR=0xff rather than 0x0 for auto pci allocation Rather than use "0x0" to signify that the hotplug slot should be automatically selected by qemu-dm, define AUTO_PHP_SLOT_STR. At the same time, change the magic value form 0x0 to 0xff, in line with changes made to qemu-dm to allow any unused PCI device to be used for hotplug. Signed-off-by: Simon Horman --- tools/python/xen/xend/XendConstants.py | 3 +++ tools/python/xen/xend/XendDomainInfo.py | 4 ++-- tools/python/xen/xend/server/pciif.py | 3 ++- tools/python/xen/xm/main.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/python/xen/xend/XendConstants.py b/tools/python/xen/xend/XendConstants.py index fa72edc5af..b1c2957a7a 100644 --- a/tools/python/xen/xend/XendConstants.py +++ b/tools/python/xen/xend/XendConstants.py @@ -135,3 +135,6 @@ VTPM_DELETE_SCRIPT = '/etc/xen/scripts/vtpm-delete' XS_VMROOT = "/vm/" +NR_PCI_DEV = 32 +AUTO_PHP_SLOT = NR_PCI_DEV +AUTO_PHP_SLOT_STR = "%02x" % NR_PCI_DEV diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index d1161944ea..0050a3ac72 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -793,7 +793,7 @@ class XendDomainInfo: existing_dev_uuid = sxp.child_value(existing_dev_info, 'uuid') existing_pci_conf = self.info['devices'][existing_dev_uuid][1] existing_pci_devs = existing_pci_conf['devs'] - vslt = '0x0' + vslt = AUTO_PHP_SLOT_STR for x in existing_pci_devs: if ( int(x['domain'], 16) == int(dev['domain'], 16) and int(x['bus'], 16) == int(dev['bus'], 16) and @@ -801,7 +801,7 @@ class XendDomainInfo: int(x['func'], 16) == int(dev['func'], 16) ): vslt = x['vslt'] break - if vslt == '0x0': + if vslt == AUTO_PHP_SLOT_STR: raise VmError("Device %04x:%02x:%02x.%01x is not connected" % (int(dev['domain'],16), int(dev['bus'],16), int(dev['slot'],16), int(dev['func'],16))) diff --git a/tools/python/xen/xend/server/pciif.py b/tools/python/xen/xend/server/pciif.py index 51189c7e78..2344de4041 100644 --- a/tools/python/xen/xend/server/pciif.py +++ b/tools/python/xen/xend/server/pciif.py @@ -24,6 +24,7 @@ from xen.xend import sxp from xen.xend import arch from xen.xend.XendError import VmError from xen.xend.XendLogging import log +from xen.xend.XendConstants import * from xen.xend.server.DevController import DevController from xen.xend.server.DevConstants import xenbusState @@ -218,7 +219,7 @@ class PciController(DevController): try: dev_dict['vslt'] = slot_list[i] except IndexError: - dev_dict['vslt'] = '0x0' + dev_dict['vslt'] = AUTO_PHP_SLOT_STR pci_devs.append(dev_dict) diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index c7bc21e523..985e21de6d 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -2456,7 +2456,7 @@ def parse_pci_configuration(args, state, opts = ''): if len(args) == 3: vslt = args[2] else: - vslt = '0x0' #chose a free virtual PCI slot + vslt = AUTO_PHP_SLOT_STR pci=['pci'] pci_match = re.match(r"((?P[0-9a-fA-F]{1,4})[:,])?" + \ r"(?P[0-9a-fA-F]{1,2})[:,]" + \ -- 2.30.2